home *** CD-ROM | disk | FTP | other *** search
/ Bath / Bath CDROM.iso / pc / BATH.DXR / Internal_3_selector.ls < prev    next >
Encoding:
Text File  |  2001-07-26  |  6.2 KB  |  213 lines

  1. property left, right, top, bottom, margin, picGap, picTop, currentPic, currentText, currentBack, currentLabel, siteLabels, channel, numPics, totalPicLength, thumbs, changed
  2. global currentSite, currentFullScreen, sitesVisited
  3.  
  4. on new me
  5.   currentSite = EMPTY
  6.   sitesVisited = []
  7.   thumbs = []
  8.   left = 10
  9.   right = 476
  10.   top = 525
  11.   bottom = 596
  12.   margin = 3
  13.   picGap = 4
  14.   picTop = 92
  15.   totalPicLength = 0
  16.   channel = 81
  17.   siteLabels = [#Abbey: "Abbey & Heritage Vaults", #Assembly_Rooms: "Assembly Rooms & Museum of Costume", #Postal_Museum: "Bath Postal Museum", #Bath_Museum: "Building of Bath Museum", #Floral: "Floral Bath", #Guildhall: "Guildhall", #Art_Museum: "Holburne Museum of Art", #Jane_Austen: "Jane Austen Centre", #Micro_World: "Impossible Microworld", #Pump_Room: "Pump Room", #Georgian_Gems: "More Georgian Gems", #Work_Museum: "Museum of Bath at Work", #Asian_Museum: "Museum of East Asian Art", #New_Spa: "New Spa", #No1: "No. 1 Royal Crescent", #Pulteney_Bridge: "Pulteney Bridge", #Roman_Baths: "Roman Baths", #Royal_Crescent: "Royal Crescent & Circus", #Sally_Lunn: "Sally Lunn's House", #Shopping: "Shopping & Entertainment", #Victoria: "Victoria Art Gallery", #Around_Bath: "Around Bath"]
  18.   return me
  19. end
  20.  
  21. on setSite me, site
  22.   if site <> currentSite then
  23.     sprite(14).visible = 0
  24.     sprite(15).visible = 0
  25.     sprite(11).visible = 0
  26.     if soundBusy(2) then
  27.       sound fadeOut 2, 100
  28.       sound stop 2
  29.     end if
  30.     currentPic = VOID
  31.     currentText = VOID
  32.     currentSite = site
  33.     currentLabel = getaProp(siteLabels, site)
  34.     changed = 1
  35.   else
  36.     changed = 0
  37.   end if
  38. end
  39.  
  40. on loadSite me
  41.   if not changed then
  42.     return 
  43.   end if
  44.   clear(me)
  45.   setBack(me, currentSite)
  46.   member("Label").text = currentLabel
  47.   sprite(15).visible = 1
  48.   fillThumbs(me)
  49.   renderThumbs(me)
  50.   setText(me, (the member of sprite channel).name)
  51.   changed = 0
  52.   set the member of sprite 11 to "icon_audio0"
  53.   sprite(11).visible = 1
  54.   if getPos(sitesVisited, currentSite) = 0 then
  55.     append(sitesVisited, currentSite)
  56.     playVoice(me, currentSite)
  57.   end if
  58. end
  59.  
  60. on clear me
  61.   setPic(me, "dummy_image")
  62.   setText(me, "dummy_text")
  63.   repeat with i in thumbs
  64.     i.member = member("dummy", 1)
  65.     i.loc = point(1000, 1000)
  66.   end repeat
  67.   thumbs = []
  68.   totalPicLength = 0
  69. end
  70.  
  71. on setPic me, pic
  72.   if member(the member of sprite 13).name = pic then
  73.     return 
  74.   end if
  75.   set the locV of sprite 16 to 1000
  76.   if pic <> VOID then
  77.     currentPic = pic
  78.   else
  79.     currentPic = (the member of sprite channel).name
  80.   end if
  81.   set the blend of sprite 13 to 0
  82.   sprite(16).visible = 0
  83.   if the number of member currentPic of castLib "Images" > 0 then
  84.     set the member of sprite 13 to member(currentPic, "Images")
  85.   else
  86.     set the memberNum of sprite 13 to 1
  87.     currentPic = member(1).name
  88.   end if
  89.   set the locV of sprite 13 to picTop + (member(currentPic, "Images").height / 2.0)
  90.   repeat with i = 1 to 5
  91.     set the blend of sprite 13 to i * 20
  92.     updateStage()
  93.   end repeat
  94.   if the number of member currentPic of castLib "captions" > 0 then
  95.     set the member of sprite 16 to member(currentPic, "captions")
  96.   else
  97.     set the memberNum of sprite 16 to 1
  98.   end if
  99.   set the locV of sprite 16 to the bottom of sprite 13 + 5
  100.   sprite(16).visible = 1
  101. end
  102.  
  103. on setText me, text
  104.   if text <> VOID then
  105.     currentText = text
  106.     if the number of member currentText of castLib "Texts" > 0 then
  107.       set the member of sprite 14 to member(currentText, "Texts")
  108.     else
  109.       if the number of member the name of the member of sprite channel of castLib "Texts" > 0 then
  110.         set the member of sprite 14 to member((the member of sprite channel).name, "Texts")
  111.       end if
  112.     end if
  113.   end if
  114. end
  115.  
  116. on setBack me, back
  117.   if back = VOID then
  118.     return 
  119.   end if
  120.   currentBack = back
  121.   if the number of member currentBack of castLib "Backgrounds" > 0 then
  122.     set the member of sprite 1 to member(currentBack, "Backgrounds")
  123.   end if
  124. end
  125.  
  126. on playVoice me, voice
  127.   if not soundBusy(2) then
  128.     set the volume of sound 2 to 255
  129.     sound(2).play(member(voice, "sounds"))
  130.   end if
  131. end
  132.  
  133. on fillThumbs me
  134.   numPics = the number of castMembers of castLib currentSite
  135.   repeat with i = 1 to numPics
  136.     thisChan = i + channel - 1
  137.     set the castLibNum of sprite thisChan to castLib(currentSite).number
  138.     set the memberNum of sprite thisChan to i
  139.     set the width of sprite thisChan to member(i, currentSite).width
  140.     set the height of sprite thisChan to member(i, currentSite).height
  141.     totalPicLength = totalPicLength + member(i, currentSite).width + picGap
  142.     append(thumbs, sprite(thisChan))
  143.   end repeat
  144. end
  145.  
  146. on renderThumbs me
  147.   buff = 0
  148.   repeat with i = 1 to count(thumbs)
  149.     getAt(thumbs, i).loc = point(left + buff + (getAt(thumbs, i).width / 2), top + margin + (getAt(thumbs, i).height / 2))
  150.     buff = buff + getAt(thumbs, i).width + picGap
  151.   end repeat
  152.   if totalPicLength < (right - left + 15) then
  153.     sprite(66).visible = 0
  154.     sprite(67).visible = 0
  155.   else
  156.     sprite(66).visible = 1
  157.     sprite(67).visible = 1
  158.   end if
  159.   repeat with i in thumbs
  160.     i.visible = 1
  161.   end repeat
  162.   updateStage()
  163. end
  164.  
  165. on Shift me, direction
  166.   found = 0
  167.   rightEdge = right
  168.   leftEdge = left
  169.   if (direction = #prior) and (thumbs[1].left < (left - picGap)) then
  170.     repeat with i = count(thumbs) down to 1
  171.       if getAt(thumbs, i).left < (left - picGap) then
  172.         leftEdge = getAt(thumbs, i).left
  173.         exit repeat
  174.       end if
  175.     end repeat
  176.     slide(thumbs, left - leftEdge)
  177.   else
  178.     if (direction = #next) and (thumbs[count(thumbs)].right > (right + picGap)) then
  179.       repeat with i in thumbs
  180.         if i.right > (right + picGap) then
  181.           rightEdge = i.right
  182.           exit repeat
  183.         end if
  184.       end repeat
  185.       slide(thumbs, -(rightEdge - right))
  186.     end if
  187.   end if
  188.   updateStage()
  189. end
  190.  
  191. on slide array, dist
  192.   if dist = 0 then
  193.     return 
  194.   end if
  195.   polarity = dist / abs(dist)
  196.   travelled = 0
  197.   speed = 10
  198.   repeat while abs(travelled) < abs(dist)
  199.     dx = min(max(1, (1 - (travelled / float(abs(dist)))) * speed), abs(dist) - abs(travelled))
  200.     repeat with i in array
  201.       i.locH = i.locH + (dx * polarity)
  202.     end repeat
  203.     updateStage()
  204.     travelled = travelled + dx
  205.   end repeat
  206. end
  207.  
  208. on wait amount
  209.   start = the ticks
  210.   repeat while (the ticks - start) < amount
  211.   end repeat
  212. end
  213.